@model IEnumerable<CooWork.Models.Department>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th></th>
        <th>
            DepartmentName
        </th>
        <th>
            parentId
        </th>
        <th>
            DepartmentDesc
        </th>
        <th>
            Leader
        </th>
        <th>
            Department1
        </th>
        <th>
            Department2
        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
        <td>
			@item.DepartmentName
        </td>
        <td>
			@item.parentId
        </td>
        <td>
			@item.DepartmentDesc
        </td>
        <td>
			@item.Leader
        </td>
        <td>
			@(item.Department1 == null ? "None" : item.Department1.Count.ToString())
        </td>
        <td>
			@Html.DisplayTextFor(_ => item.Department2).ToString()
        </td>
    </tr>
}

</table>


